package com.longge;

import java.util.HashMap;
import java.util.Map;

/**
 * @创建人 xinglongge
 * @创建时间 2021/7/22
 * @描述
 */
public class HammingWeight {
    public int hammingWeight(int n) {
        int res = 0;
        while (n != 0) {
            if ((n & 1) == 1) {
                res++;
            }
            n= n>>>1;
        }
        return res;
    }

}
